#include "widget.h"
#include "ui_widget.h"
#include <QResizeEvent>
#include <QDebug>

Widget::Widget(QWidget *parent)
    : QWidget(parent)
    , ui(new Ui::Widget)
{
    ui->setupUi(this);
    label=new QLabel(this);
    //获取窗口大小
    QRect rec=this->geometry();
    //给label进行设置同等大小的宽和高
    label->setGeometry(0,0,rec.width(),rec.height());
    //将图片设置进去
    QPixmap picture(":/itachi.png");
    label->setPixmap(picture);
    label->setScaledContents(true);

}

Widget::~Widget()
{
    delete ui;
}

void Widget::resizeEvent(QResizeEvent *event)
{
    qDebug()<<event->size();
    label->setGeometry(0,0,event->size().width(),event->size().height());//将label的宽度不停的随着窗口大小改变
}


